<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <canvas id="canvas" width="400" height="400"></canvas>
    <script src="utils.js"></script>
    <script>
        window.onload = function(){
            var canvas = document.getElementById('canvas'),
                context = canvas.getContext('2d'),
                angle =0,
                range = 50,
                centerY = canvas.height/2,
                speedX = 1,
                speedY = 0.05,
                posX = 0,
                posY = centerY
            context.lineWidth = 2

            function drawFrame(){
                window.requestAnimationFrame(drawFrame, canvas)

                context.beginPath()
                context.moveTo(posX, posY)
                posX += speedX
                angle += speedY
                posY = centerY + Math.sin(angle)*range
                context.lineTo(posX, posY)
                context.stroke()
            }
            drawFrame()
        }
    </script>
</body>
</html>